﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using IHISCETeim.BLL;
using IHISCETeim.Library;
using IHISCETeim.Model;
namespace IHISCETeim.Web.MachineSys.MacModel
{
    public partial class ODailyEdit : PageBase
    {
        protected override Permission[] PowerKey
        {
            get
            {
                return new Permission[] { Permission.修改 };
            }
        }
        protected override string DWZRef
        {
            get { return "ODailyList"; }
        }

        #region
        /// <summary>
        /// 需要修改的用户ID
        /// </summary>
        protected int DailyId
        {
            get
            {
                return GetRequestValue<int>("DailyId");
            }
        }

        private ODailyInfo _obj;
        protected ODailyInfo obj
        {
            get
            {
                if (_obj == null)
                    _obj =ODailyController.GetById(DailyId);
                return _obj;
                //OMenuController.ge
            }
        }
      
        #endregion

        protected void Page_Load(object sender, EventArgs e)
        {
            if (GetRequestValue<string>("ajaxmethod", "") == "editdaily")
            {
                addmenu();
            }
        }

        protected void addmenu()
        {
            ODailyInfo obj2 = Request.SerializableObject<ODailyInfo>();

            //if (OUserController.CheckUserName(obj.UserName))
            //{
            //    AlertJson("登陆帐户名已存在,请重新输入.");
            //    return;
            //}
            obj2.JobCode = string.IsNullOrEmpty(obj2.JobCode) ? obj2.JobCode : obj2.JobCode.ToUpper();
            obj2.GongWei = string.IsNullOrEmpty(obj2.GongWei) ? obj2.GongWei : obj2.GongWei.ToUpper(); 
            obj2.SerialNumber = string.IsNullOrEmpty(obj2.SerialNumber) ? obj2.SerialNumber : obj2.SerialNumber.ToUpper();
            List<OJobContentInfo> allJobCon = OJobController.GetALLJobContent();
            OJobContentInfo tempobj = allJobCon.First<OJobContentInfo>(e => e.JobCode == obj2.JobCode);
            obj2.JobTitle = tempobj.JobTitle;

            this.AddLog(Permission.修改, obj, obj2);
            if (ODailyController.Update(obj2))
                SuccessJson("修改成功", "");
            else
                ErrorJson("修改失败", "");
        }
    }
}